<!-- Views/news/index.php -->  
  
<div class="header-with-link">  
    <h2><?= esc($title) ?></h2>  
    <div class="add-new-link">  
        <a href="<?= site_url('news/new') ?>">add a new news item</a>  
    </div>  
</div>  
  
<?php if ($news_list !== []): ?>  
    <ul>  
        <?php foreach ($news_list as $news_item): ?>  
            <li>  
                <h3><?= esc($news_item['title']) ?></h3>  
                <div class="main">  
                    <?= esc($news_item['body']) ?>  
                </div>  
                <p>  
                    <a href="<?= site_url('news/' . esc($news_item['slug'], 'url')) ?>">View article</a> |  
                    <a href="<?= site_url('news/delete/' . $news_item['id']) ?>" onclick="return confirm('Are you sure you want to delete this news item?')">Delete</a>  
                </p>  
            </li>  
        <?php endforeach; ?>  
    </ul>  
<?php else: ?>  
    <h3>No News</h3>  
    <p>Unable to find any news for you.</p>  
<?php endif; ?>  
  
<!-- ... 其他代码 ... -->
<!-- ... 其他代码 ... -->
<style>  
    .header-with-link {  
        display: flex;  
        align-items: center;  
    }  
    .header-with-link h2 {  
        margin-right: 20px; /* 根据需要调整间距 */  
    }  
    .add-new-link {  
        /* 您可以根据需要添加更多样式 */  
    }  
</style>